package com.lagou.edu.service;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.lagou.edu.utils.Result;

/**
 * @author zjy
 * @date: 2020/5/24 12:45 下午
 */
public class SentinelHandlers {

    /**
     * 被流量控制和降级时处理逻辑
     * @param emailAddress
     * @param blockException
     * @return
     */
    public static Result generateCodeHandle(String emailAddress, BlockException blockException){
        return Result.error("请勿频繁操作");
    }

    /**
     * 发生Java异常时处理逻辑
     * @param emailAddress
     * @return
     */
    public static Result generateCodeFallBack(String emailAddress){
        return Result.error("发生未知错误，请稍后再试");
    }

    public static Integer validateCodeHandle(String emailAddress,String code, BlockException blockException){
        return -100;
    }

    public static Integer validateCodeFallBack(String emailAddress){
        return -500;
    }
}
